package jlu.zqq.struts.action;

import jlu.zqq.dao.UserDAO;
import jlu.zqq.po.User;

public class UpdateUserAction extends BaseAction {
	/**
	 * 
	 */
	private static final long serialVersionUID = -826199476082182540L;
	
	private String uname ;
	private String password ;
	private String newpwd ;
	private String realname ;
	private String phone ;

	@Override 
    public String execute() throws Exception { 
		User user = (User)(getSessionMap().get("user"));
		if(password.equals(user.getPassward())){
			UserDAO dao = new UserDAO() ;
			user.setUname(uname);
			user.setPassward(newpwd);
			user.setRealname(realname);
			user.setPhone(phone);
			dao.updateUser(user);
			getSessionMap().remove("user");
	        getSessionMap().remove("rname") ;
			return SUCCESS ;
		}else{
			return INPUT; 
		}
    } 
	
	public String getUname() {
		return uname;
	}
	public void setUname(String uname) {
		this.uname = uname;
	}

	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}

	public String getNewpwd() {
		return newpwd;
	}
	public void setNewpwd(String newpwd) {
		this.newpwd = newpwd;
	}

	public String getRealname() {
		return realname;
	}
	public void setRealname(String realname) {
		this.realname = realname;
	}

	public String getPhone() {
		return phone;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	}

}
